package com.caseProject.puremvc.mediator.gui
{
	import com.caseProject.puremvc.mediator.events.GraphicEvent;
	
	import flash.events.Event;
	import flash.geom.Point;
	
	import org.drawlineapi.tools.IndicativeLine;

	public class Transition extends Graphic
	{
		private var line:IndicativeLine;
		private var _fromPoint:Point;
		private var _toPoint:Point;
		
		public function Transition()
		{
			super();
			
			this._fromPoint = new Point(0,0);
			this._toPoint = new Point(0,0);
			
			this.draw();
		}
		
		override protected function onSelectDel(event:Event):void
		{
			this.dispatchEvent(new GraphicEvent(GraphicEvent.DELETE_TRANSITION, this.vo, true));
			this.parent.removeChild(this);			
		}
		
		override public function draw ():void
		{
			super.draw();
			
			line = new IndicativeLine(this.fromPoint, this.toPoint);
			var seta:SetaSWC = new SetaSWC ();
			seta.mouseChildren = false;
			seta.mouseEnabled = false;
			line.changeEndIcon(seta);
			line.desableStartIcon();
			this.addChild(line);
		}
		
		public function get toPoint():Point
		{
			return _toPoint;
		}

		public function set toPoint(value:Point):void
		{
			_toPoint = value;
			this.line.to = value; //Atualiza posição
		}

		public function get fromPoint():Point
		{
			return _fromPoint;
		}

		public function set fromPoint(value:Point):void
		{
			_fromPoint = value;
			this.line.from = value;
		}	
	}
}